/**
 */
package OBSL.impl;

import OBSL.Individual;
import OBSL.OBSLPackage;
import OBSL.Parameter;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Parameter</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link OBSL.impl.ParameterImpl#getValueFor <em>Value For</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class ParameterImpl extends MinimalEObjectImpl.Container implements Parameter {
	/**
	 * The cached value of the '{@link #getValueFor() <em>Value For</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValueFor()
	 * @generated
	 * @ordered
	 */
	protected Individual valueFor;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ParameterImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return OBSLPackage.Literals.PARAMETER;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Individual getValueFor() {
		if (valueFor != null && valueFor.eIsProxy()) {
			InternalEObject oldValueFor = (InternalEObject)valueFor;
			valueFor = (Individual)eResolveProxy(oldValueFor);
			if (valueFor != oldValueFor) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, OBSLPackage.PARAMETER__VALUE_FOR, oldValueFor, valueFor));
			}
		}
		return valueFor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Individual basicGetValueFor() {
		return valueFor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetValueFor(Individual newValueFor, NotificationChain msgs) {
		Individual oldValueFor = valueFor;
		valueFor = newValueFor;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, OBSLPackage.PARAMETER__VALUE_FOR, oldValueFor, newValueFor);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setValueFor(Individual newValueFor) {
		if (newValueFor != valueFor) {
			NotificationChain msgs = null;
			if (valueFor != null)
				msgs = ((InternalEObject)valueFor).eInverseRemove(this, OBSLPackage.INDIVIDUAL__PARAMETERIZED_BY, Individual.class, msgs);
			if (newValueFor != null)
				msgs = ((InternalEObject)newValueFor).eInverseAdd(this, OBSLPackage.INDIVIDUAL__PARAMETERIZED_BY, Individual.class, msgs);
			msgs = basicSetValueFor(newValueFor, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OBSLPackage.PARAMETER__VALUE_FOR, newValueFor, newValueFor));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case OBSLPackage.PARAMETER__VALUE_FOR:
				if (valueFor != null)
					msgs = ((InternalEObject)valueFor).eInverseRemove(this, OBSLPackage.INDIVIDUAL__PARAMETERIZED_BY, Individual.class, msgs);
				return basicSetValueFor((Individual)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case OBSLPackage.PARAMETER__VALUE_FOR:
				return basicSetValueFor(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case OBSLPackage.PARAMETER__VALUE_FOR:
				if (resolve) return getValueFor();
				return basicGetValueFor();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case OBSLPackage.PARAMETER__VALUE_FOR:
				setValueFor((Individual)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case OBSLPackage.PARAMETER__VALUE_FOR:
				setValueFor((Individual)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case OBSLPackage.PARAMETER__VALUE_FOR:
				return valueFor != null;
		}
		return super.eIsSet(featureID);
	}

} //ParameterImpl
